package o;

import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.downloadengine.api.SplitTask;
import java.util.Collection;
import java.util.List;

public final class dwm {
    private static final Object ˎ = new Object();
    private static dwm ˏ = null;
    private cfu ˋ = euc.ˊ().ʽ("LocaleSessionDldTaskEx");
    private cfu ॱ = euc.ˊ().ʽ("LocaleSplitTaskEx");

    private dwm() {
    }

    public static dwm ॱ() {
        dwm o_dwm;
        synchronized (ˎ) {
            if (ˏ == null) {
                ˏ = new dwm();
            }
            o_dwm = ˏ;
        }
        return o_dwm;
    }

    public void ˏ(SessionDownloadTask sessionDownloadTask) {
        Logger.ˎ("LocaleChangeDAO", "insert SessionDownloadTask");
        if (sessionDownloadTask.ˊˊ() != null) {
            ˏ(sessionDownloadTask.ʾ());
            this.ˋ.ˎ((cfr) sessionDownloadTask);
            if (!CollectCheck.isEmpty(sessionDownloadTask.ᐝˊ())) {
                for (cfr ˎ : sessionDownloadTask.ᐝˊ()) {
                    this.ॱ.ˎ(ˎ);
                }
            }
        }
    }

    private void ˏ(long j) {
        for (SessionDownloadTask ˎ : this.ˋ.ˋ(SessionDownloadTask.class, "sessionId_=?", new String[]{String.valueOf(j)}, null, null)) {
            ˎ(ˎ);
        }
    }

    public void ˎ(SessionDownloadTask sessionDownloadTask) {
        Logger.ˎ("LocaleChangeDAO", "SessionDownloadDAO deleteTask, package=" + sessionDownloadTask.ˊˊ());
        this.ˋ.ˋ("sessionId_=?", new String[]{String.valueOf(sessionDownloadTask.ʾ())});
        this.ॱ.ˋ("sessionId_=?", new String[]{String.valueOf(sessionDownloadTask.ʾ())});
    }

    public List<SessionDownloadTask> ˋ() {
        Logger.ˎ("LocaleChangeDAO", "SessionDownloadDAO getAllTask");
        List<SessionDownloadTask> ˋ = this.ˋ.ˋ(SessionDownloadTask.class, null);
        for (SessionDownloadTask sessionDownloadTask : ˋ) {
            Collection ˎ = ˎ(sessionDownloadTask.ʾ());
            sessionDownloadTask.ᐝˊ().clear();
            sessionDownloadTask.ᐝˊ().addAll(ˎ);
        }
        return ˋ;
    }

    private List<SplitTask> ˎ(long j) {
        return this.ॱ.ˋ(SplitTask.class, "sessionId_=?", new String[]{String.valueOf(j)}, null, null);
    }
}
